<?php
class Country extends CountryPeer
{
	function Country()
	{
		parent::CountryPeer();
	}

	public static function getAllCountries()
	{		
		$db = new Database();
		$query = "SELECT id FROM country";
		$result = $db->query($query);
		
		$ids = $db->fetch_array($result);		
		$countries = array();

		foreach ($ids as $id) {
			$country = new Country();
			$country->select($id['id']);			
			$countries[] = $country;
		}
		
		return $countries;
	}
	
	function getAllLocations()
	{
		$db = new Database();
		$query = "SELECT id FROM location WHERE country = ".$this->getid()."";
		$db->query($query);
		
		$ids = $db->fetch_array($db->result);		
		$locations = array();

		foreach ($ids as $id) {
			$location = new Location();
			$location->select($id['id']);
			$locations[] = $location;
		}
		
		return $locations;
	}
}
?>